var jDdlAIMCBoardCategory = $('#ctl00_ContentPlaceHolder1_aFundQuickrankControl_ddlAIMCBoardCategory');
var jDdlAIMCCategory = $('#ctl00_ContentPlaceHolder1_aFundQuickrankControl_ddlAIMCCategory');
var aimcBoardMapper = null;
$.data(document.body, 'aimc_category', eval(new function() {
    var options = [];
    $.map(jDdlAIMCCategory.find('option').toArray(), function(n) {
        options.push({
            'boardid': $(n).val().split('|')[0],
            'categoryid': $(n).val().split('|')[1]
        });
    });
    aimcBoardMapper = options;
    return options;
}));

jDdlAIMCCategory.find('option:gt(0)').remove();/*Remove whole apart first option.*/
jDdlAIMCBoardCategory.unbind('chagne');
jDdlAIMCBoardCategory.change(function() {
    jDdlAIMCCategory.find('option').remove();
    jDdlAIMCCategory.append('<option style="display:inline;" value="|" selected="selected">----------------------</option>');
    $.map(aimcBoardMapper, function(n) {
        if (n.boardid == $(jDdlAIMCBoardCategory.find('option:selected')[0]).val()) {
            jDdlAIMCCategory.append('<option style="display:inline;" value="' + n.categoryid + '">' + n.categoryid + '</option>');
        }
    });
});